home *** CD-ROM | disk | FTP | other *** search
- #include <Quickdraw.h>
- #include <Resources.h>
- #include <Memory.h>
- #include <Events.h>
-
- #include "acur.h"
-
- #define SPIN_DELAY 15L
-
- typedef struct {
- short count;
- short counter;
- short id;
- short padd;
- } acur, *acurptr, ** acurhand;
-
- static acurptr aptr = nil;
- static long lastspin = 0;
-
- void Initacur(short id)
- {
- Handle rhand;
- short count;
- short *id_base;
- CursHandle cur;
-
- rhand = GetResource('acur', id);
- if ((ResError() == noErr) && (rhand != nil)) {
- LoadResource(rhand);
- HLock(rhand);
- HNoPurge(rhand);
- if (MemError() != noErr) {
- return;
- }
- aptr = (acurptr)*rhand;
- aptr->counter = 0;
- id_base = & (aptr->id);
-
- for (count = aptr->count; count > 0; count--) {
- cur = (CursHandle) GetResource('CURS', id_base[(aptr->count - count)<<1]);
- if (cur == nil) {
- return;
- }
- HLock((Handle)cur);
- HNoPurge((Handle)cur);
- }
- }
- lastspin = TickCount();
- }
-
- void SpinCursor()
- {
- CursHandle cur;
- short* id_base;
-
- extern void HandleEvent(void);
-
- if ((TickCount() - lastspin) >= SPIN_DELAY) {
- HandleEvent();
- lastspin = TickCount();
- if (aptr != nil) {
- aptr->counter++;
- if (aptr->counter >= aptr->count) {
- aptr->counter = 0;
- }
- id_base = & (aptr->id);
- cur = (CursHandle) GetResource('CURS', id_base[(aptr->counter)<<1]);
- if (cur != nil) {
- SetCursor(*cur);
- }
- }
- }
- }
-
- void DisposAcur()
- {
- CursHandle cur;
- Handle rhand;
- short count, *id_base;
-
- rhand = RecoverHandle((Ptr)aptr);
-
- if (rhand != nil) {
- id_base = & (aptr->id);
- for (count = aptr->count; count > 0; count--) {
- cur = (CursHandle) GetResource('CURS', id_base[(aptr->count - count)<<1]);
- if (cur != nil) {
- ReleaseResource((Handle)cur);
- }
- }
- ReleaseResource(rhand);
- }
- }
-